﻿@model DHQGHN.PM2.Models.Online.LaborAndJobModel


<link href="~/Content/standard_form_nhaplieu.css" rel="stylesheet" />
<script>
    @functions{
        public string GetAntiForgeryToken()
        {
            string cookieToken, formToken;
            AntiForgery.GetTokens(null, out cookieToken, out formToken);
            return cookieToken + "," + formToken;
        }
    };

    $(document).ready(function () {
        $("#divLoading").show();
        $("#btnNext").attr("disabled", "disabled");
        $("#btnBack").attr("disabled", "disabled");
        $.ajax({
            url: '@Url.Action("GetAllByListName")',
            dataType: 'json',
            headers: {
                'VerificationToken': '@GetAntiForgeryToken()'
            },
            method: 'GET',
            data: { 'tablename': 'OCCUP_STATUS' },
            success: function (data, textStatus, jqXHR) {
                $(".OCCUP_STATUS_ID").append('<option value="">' +
          '-- Chọn Tình trạng việc làm --' + '</option>');
                $.each(data, function (i, item) {
                    $(".OCCUP_STATUS_ID").append('<option value="' + item.CodeID + '">' +
                         item.Name + '</option>');
                });
                $(".OCCUP_STATUS_ID").val("@Model.OCCUP_STATUS_ID");
            },
            complete: function () {
                Check();
            }

        });
        $.ajax({
            url: '@Url.Action("GetAllByListName")',
            dataType: 'json',
            headers: {
                'VerificationToken': '@GetAntiForgeryToken()'
            },
            method: 'GET',
            data: { 'tablename': 'OCCUPATION' },
            success: function (data, textStatus, jqXHR) {
                $(".OCCUPATION_ID").append('<option value="">' +
          '-- Chọn Nghề nghiệp --' + '</option>');
                $.each(data, function (i, item) {
                    $(".OCCUPATION_ID").append('<option value="' + item.CodeID + '">' +
                         item.Name + '</option>');

                });
                $(".OCCUPATION_ID").val("@Model.OCCUPATION_ID");
            },
            complete: function () {
                Check();
            }

        });
        $("#btnNext").click(function (event, giatri) {
            if (checkhtml()) {
                alert("Dữ liệu nhập không được có ký tự '<' ở đầu.");
            } else {
                if (giatri != null) {
                    ClickButton(giatri);
                }
                else {
                    ClickButton(1);
                }
            }
        });
        $("#btnBack").click(function () {
            if (checkhtml()) {
                alert("Dữ liệu nhập không được có ký tự '<' ở đầu.");
            } else {
                ClickButton(0);
            }
        });
    });

    function ClickButton(Next) {
        $("#divLoading").show();
        var dataSend = {
            'HOUSEHOLD_ID': $("#HOUSEHOLD_ID").val(),
            'RESIDENT_ID': $("#RESIDENT_ID").val(),
            'OCCUPATION_ID': $(".OCCUPATION_ID").val(),
            'WORK_PLACE': $("#WORK_PLACE").val(),
            'OCCUP_STATUS_ID': $(".OCCUP_STATUS_ID").val(),
            'NEXT': Next,

        };
        var jqXHR = $.ajax({
            url: '@Url.Action("LaborAndJobPartial","Online")',
            dataType: 'html',
            headers: {
                'VerificationToken': '@GetAntiForgeryToken()'
            },
            method: 'post',
            cache: false,
            data: dataSend,
            success: function myfunctionSuccess(data, textStatus, jqXHR) {
                if (Next == "2") {
                    $('#formLogin').html(data);
                }
                else {
                    $('#loadPartial').html(data);
                }
            },
            complete: function (jqXHR, textStatus) {
                $("#divLoading").hide();
                $("#btnNext").removeAttr("disabled");
                $("#btnBack").removeAttr("disabled");
            },
            error: function (jqXHR, textStatus, errorThrown) {
                alert('Có lỗi xảy ra trong quá trình lưu thông tin: ' + errorThrown);
            },

        });
    }
    function Check() {
        var OCCUPATION_ID1 = $(".OCCUPATION_ID").val();
        var coun = $("#OCCUPATION_ID").val();
        var OCCUP_STATUS_ID1 = $(".OCCUP_STATUS_ID").val();
        var coun1 = $("#OCCUP_STATUS_ID").val();
        if (OCCUPATION_ID1 == coun && OCCUP_STATUS_ID1 == coun1) {
            $("#divLoading").hide();
            $("#btnNext").removeAttr("disabled");
            $("#btnBack").removeAttr("disabled");
        }
        else {
            $("#divLoading").show();
            $("#btnNext").attr("disabled", "disabled");
            $("#btnBack").attr("disabled", "disabled");
        }

    };

</script>

<div class="noidung-nhaponline">
    <div class="login-fields2">
        <p style="float: left; padding-right: 5px; vertical-align: top;">
            <img src="../Images/rt_arrow.gif">
        <p>Thông tin Lao động và việc làm:</p>
    </div>
    <div class="row row-online-table">
        <div class="col-md-4 lbl-online1">
            @Html.LabelFor(model => model.OCCUPATION_ID, new { @class = "control-label" })
        </div>
        <div class="col-md-5">
            <select class="OCCUPATION_ID form-control"></select>
        </div>
    </div>
    <div class="row row-online-table">
        <div class="col-md-4 lbl-online1">
            @Html.LabelFor(model => model.WORK_PLACE, new { @class = "control-label" })
        </div>
        <div class="col-md-5">
            @Html.TextBoxFor(model => model.WORK_PLACE, new { @class = "form-control ", MaxLength = 255 })
        </div>
    </div>
    <div class="row row-online-table">
        <div class="col-md-4 lbl-online1">
            @Html.LabelFor(model => model.OCCUP_STATUS_ID, new { @class = "control-label" })
        </div>
        <div class="col-md-5">
            <select class="OCCUP_STATUS_ID form-control"></select>
        </div>
    </div>
    <div>
        @Html.HiddenFor(model => model.RESIDENT_ID)
        @Html.HiddenFor(model => model.HOUSEHOLD_ID)
        @Html.HiddenFor(model => model.OCCUP_STATUS_ID)
        @Html.HiddenFor(model => model.OCCUPATION_ID)
    </div>
    <center>
        <input type="button" class="btn btn-small btn-small_online btn-success buttonClick " id="btnBack" value="<< Quay lại">
        <input type="button" class="btn btn-small btn-small_online btn-success buttonClick" id="btnNext" value="Tiếp tục >>">
    </center>
</div>



